package mdm.led.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;

import mdm.led.dao.DepartmentMapper;
import mdm.led.dao.DopeMapper;
import mdm.led.dao.ThreeCureIssueMapper;
import mdm.led.dao.ThreeItemMapper;
import mdm.led.dao.ThreeTableMapper;
import mdm.led.dao.ThreeTaskAllotMapper;
import mdm.led.dao.ThreeTaskExternalMapper;
import mdm.led.dao.ThreeTaskSelfMapper;
import mdm.led.dao.UserMapper;
import mdm.led.entity.Dope;
import mdm.led.entity.User;
import mdm.led.entity.department.Department;
import mdm.led.entity.three.CureIssueList;
import mdm.led.entity.three.ExternalSelfItems;
import mdm.led.entity.three.FindSelfCheckInspector;
import mdm.led.entity.three.FindThreeTaskSelf;
import mdm.led.entity.three.InsertCureIssue;
import mdm.led.entity.three.ReceiIissueMan;
import mdm.led.entity.three.SelfMan;
import mdm.led.entity.three.ThreeCureIssue;
import mdm.led.entity.three.ThreeItem;
import mdm.led.entity.three.ThreeMainList;
import mdm.led.entity.three.ThreeTable;
import mdm.led.entity.three.ThreeTaskAllot;
import mdm.led.entity.three.ThreeTaskExternal;
import mdm.led.entity.three.ThreeTaskSelf;
import mdm.led.entity.three.UpdateThreeTaskAllot;
import mdm.led.service.ThreeTableService;

/**
 *
 * @author :Monarch丿He
 * @date :2018年12月13日
 * @explain :
 */
@Service("threeTableService")
public class ThreeTableServiceImpl implements ThreeTableService {

	private Logger logger = Logger.getLogger(ThreeTableServiceImpl.class);
	@Autowired
	private ThreeTableMapper threeTableDao;
	@Autowired
	private ThreeItemMapper threeItemDao;
	@Autowired
	private DepartmentMapper departmentDao;
	@Autowired
	private ThreeTaskAllotMapper taskAllotDao;
	@Autowired
	private UserMapper userDao;
	@Autowired
	private ThreeTaskSelfMapper threeTaskSelfDao;
	@Autowired
	private ThreeCureIssueMapper cureIssueDao;
	@Autowired
	private ThreeTaskExternalMapper taskExternalDao;
	@Autowired
	private DopeMapper dopeDao;

	@Override
	public Boolean addThreeTable(ThreeTable table) throws Exception {
		// 标识位
		Boolean flag = false;

		// 检查项
		List<ThreeItem> items = table.getItems();
		// 存储表格信息
		Integer tableID = threeTableDao.addThreeTable(table);
		if (tableID > 0) {
			logger.info("\n应添加: " + items.size() + "次");
			int iRet = 0;
			for (ThreeItem threeItem : items) {
				// 赋值检查项 说对应的三查表
				threeItem.setThreeid(table.getThreeid());
				// 存储检查项
				Integer addThreeItem = threeItemDao.addThreeItem(threeItem);
				if (addThreeItem > 0)
					iRet++;
			}

			logger.info("\n成功添加: " + iRet + "次");
			if (iRet == items.size()) {
				// 添加任务
				if (!addThreeTaskAllot(table)) {
					return flag;
				}
				flag = true;
			}
		}

		return flag;
	}

	@Override
	public Integer updateThreeTable(ThreeTable table) throws Exception {
		return threeTableDao.updateThreeTable(table);
	}

	@Override
	public List<ThreeTable> findThreeTables(ThreeTable table) throws Exception {
		// 三查表格集合
		List<ThreeTable> findThreeTables = threeTableDao.findThreeTables(table);
		// 检查项实例
		ThreeItem threeItem = new ThreeItem();
		// 检查项集合
		for (ThreeTable item : findThreeTables) {

			// 赋值检查项所对应的三查表 Id
			threeItem.setThreeid(item.getThreeid());
			// 查询当前三查表所有检查项
			List<ThreeItem> findThreeItem = threeItemDao.findThreeItem(threeItem);
			// 添加到三查表实例
			item.setItems(findThreeItem);
			// start 获取部门集合
			List<Department> departments = new ArrayList<>();
			// 部门ID 数组
			String[] split = item.getDepartment().split(",");
			// 部门实例
			Department findDepartmentById = null;
			for (int i = 0; i < split.length; i++) {
				findDepartmentById = departmentDao.findDepartmentById(Integer.parseInt(split[i]));
				// 部门ID 为键 名称为值
				departments.add(findDepartmentById);
			}
			// end
			// 将部门 集合添加到 三查表实体
			item.setDepartments(departments);

		}

		return findThreeTables;
	}

	@Override
	public ThreeTable findThreeTableById(Integer id) throws Exception {
		// 根据Id 查询三查表信息
		ThreeTable findThreeTableById = threeTableDao.findThreeTableById(id);
		// 检查项实例
		ThreeItem itemObj = new ThreeItem();
		// 赋值检查项所对应的三查表 Id
		itemObj.setThreeid(findThreeTableById.getThreeid());
		List<ThreeItem> findThreeItem = threeItemDao.findThreeItem(itemObj);
		// 添加到三查表实例
		findThreeTableById.setItems(findThreeItem);
		// start 获取部门集合
		List<Department> departments = new ArrayList<>();
		// 部门ID 数组
		String[] split = findThreeTableById.getDepartment().split(",");
		// 部门实例
		Department findDepartmentById = null;
		for (int i = 0; i < split.length; i++) {
			findDepartmentById = departmentDao.findDepartmentById(Integer.parseInt(split[i]));
			if (findDepartmentById != null) {
				// 部门ID 为键 名称为值
				departments.add(findDepartmentById);
			}
		}
		// end
		findThreeTableById.setDepartments(departments);

		return findThreeTableById;
	}

	/**
	 * 添加任务
	 * 
	 * @param table
	 * @return
	 */
	public boolean addThreeTaskAllot(ThreeTable table) {
		Boolean flag = false;
		try {
			// 1:获取所有部门
			String[] split = table.getDepartment().split(",");
			// 2:获取业务口 自查类型
			Integer selftype = table.getSelftype();
			// 3:获取检查人 二级部门负责人 对应业务口
			ArrayList<User> arrayList = new ArrayList<User>();
			// 循环查询 表格指定部门 负责人 放入arratList
			for (String departmentID : split) {
				// 当前部门所有负责人
				List<User> findChargeMan = userDao.findChargeMan(Integer.parseInt(departmentID), "负责人");
				// 循环筛选指定业务口 并添加到 arratList
				for (User user : findChargeMan) {
					// 获取当前用户业务口标签
					String businessflag = user.getBusinessflag();
					if (businessflag == null || businessflag.equals("")) {
						continue;
					}
					// 分割成数组
					String[] split2 = businessflag.split(",");
					// Stirng 数组转 String List
					List<String> asList = Arrays.asList(split2);
					// 判断当前部门下的当前负责人是否对应当前业务口
					boolean contains = asList.contains(selftype.toString());
					if (contains) {
						// 添加到集合
						arrayList.add(user);
					}
				}
			}
			// 循环所有检查人 添加任务
			// 任务实例
			ThreeTaskAllot taskAllot = null;
			// 次数标识
			int iRet = 0;
			for (User user : arrayList) {
				// 任务实例化
				taskAllot = new ThreeTaskAllot();
				taskAllot.setDutyMan(user.getcUserId());
				taskAllot.setThreeID(table.getThreeid());
				// 保存数据
				Integer addThreeTaskAllot = taskAllotDao.addThreeTaskAllot(taskAllot);
				if (addThreeTaskAllot > 0) {
					iRet++;
				}
			}
			logger.info("\n=====成功添加:  " + iRet + "  个任务====\n");
			flag = true;
		} catch (Exception e) {
			flag = false;
			e.printStackTrace();
		}

		return flag;
	}

	@Override
	public Integer updateThreeTaskAllot(UpdateThreeTaskAllot taskAllot) {
		int falg = 0;
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// 当前时间字符串
		String time = dateFormat.format(new Date());
		// 自查用户 字符串 分割为 集合
		List<String> asList = Arrays.asList(taskAllot.getSelfManStr().split(","));
		ThreeItem threeItem = new ThreeItem();
		threeItem.setThreeid(taskAllot.getTableID());
		// 三查表对应检查项
		List<ThreeItem> items = threeItemDao.findThreeItem(threeItem);
		// 次数标识
		int iRet = 0;
		// 个人任务
		ThreeTaskSelf taskSelf = null;
		// 循环自查用户 添加自查任务
		for (String item : asList) {
			taskSelf = new ThreeTaskSelf();
			// 根据自查人
			Integer departmentId = userDao.selectById(taskAllot.getDutyMan()).getDepartmentId();
			taskSelf.setDepartment(departmentId);
			taskSelf.setThreeID(taskAllot.getTableID());
			taskSelf.setSelfMan(Integer.parseInt(item));
			// 添加自查任务
			Integer addThreeTaskSelf = threeTaskSelfDao.addThreeTaskSelf(taskSelf);
			if (addThreeTaskSelf > 0) {
				for (ThreeItem item2 : items) {
					item2.setThreeid(null);
					item2.setDetailsid(taskSelf.getTaskID());
					// 添加自查任务检查项
					threeItemDao.addThreeItem(item2);
				}
				iRet++;
			}
		}
		logger.info("\n======== 成功添加 :" + iRet + " 个自查任务 ======\n");
		// 修改 任务为已分配
		falg = taskAllotDao.updateThreeTaskAllot(taskAllot.getTaskID(), time);

		return falg;
	}

	@Override
	public List<ThreeTaskAllot> findThreeTaskAllot(Integer id) {
		// 查询当前用户 (检查人)
		List<ThreeTaskAllot> taskAllots = taskAllotDao.findThreeTaskAllot(id);
		// 用户部门ID
		Integer departmentId = userDao.selectById(id).getDepartmentId();
		// 检查人所在部门
		Department de = departmentDao.findDepartmentById(departmentId);
		// 部门类型 2:科室 3:大队
		Integer type = de.getType();
		// 第一层键 部门名 list >> map 键 用户ID 值 用户名
		SelfMan selfMan = null;
		List<SelfMan> selfMans = null;
		for (ThreeTaskAllot item : taskAllots) {
			// 集合实例化
			selfMans = new ArrayList<>();
			Integer tabletype = threeTableDao.findThreeTableById(item.getThreeID()).getTabletype();
			if (item.getReceiveTime() == null) {
				item.setReceiveTime("");
			}

			if (type == 2) {
				selfMan = new SelfMan();
				selfMan.setDid(de.getId());
				selfMan.setDname(de.getName());

				List<User> findChargeMan2 = userDao.findChargeMan(de.getId(), "民警");
				List<User> findChargeMan3 = userDao.findChargeMan(de.getId(), "协警");
				List<User> appointListAddUser = appointListAddUser(null, findChargeMan2);
				List<User> appointListAddUser2 = appointListAddUser(appointListAddUser, findChargeMan3);
				selfMan.setUsers(appointListAddUser2);
				selfMans.add(selfMan);
			} else if (type == 3) {
				// 部门实例
				Department department = new Department();
				// 负责父级部门
				department.setFatherid(departmentId);
				// 查询指定父级部门的部门
				List<Department> findDepartment = departmentDao.findDepartment(department);

				// 查询指定部门指定职位的用户
				for (Department deItem : findDepartment) {
					selfMan = new SelfMan();
					selfMan.setDid(deItem.getId());
					selfMan.setDname(deItem.getName());

					if (tabletype == 1) {// 内部表
						List<User> findChargeMan2 = userDao.findChargeMan(deItem.getId(), "民警");
						List<User> findChargeMan3 = userDao.findChargeMan(deItem.getId(), "协警");

						List<User> appointListAddUser = appointListAddUser(null, findChargeMan2);
						List<User> appointListAddUser2 = appointListAddUser(appointListAddUser, findChargeMan3);

						selfMan.setUsers(appointListAddUser2);
					} else { // 外部表
						List<User> findChargeMan2 = userDao.findChargeMan(deItem.getId(), "民警");

						selfMan.setUsers(findChargeMan2);
					}
					// 添加到集合
					selfMans.add(selfMan);
				}
			}

			// set到待查任务实例
			item.setSelfMans(selfMans);
		}

		return taskAllots;
	}

	public List<User> appointListAddUser(List<User> list, List<User> users) {
		if (list == null) {
			list = new ArrayList<>();
		}
		for (User user : users) {
			list.add(user);
		}
		return list;
	}

	@Override
	public List<ThreeMainList> findThreeMainList(Integer id, String name) {
		List<ThreeMainList> manList = threeTableDao.findThreeMainList(id, name);
		// 自增序列
		Integer integer = 0;
		for (ThreeMainList item : manList) {
			integer++;
			item.setOrderID(integer);
		}
		return manList;
	}

	@Override
	public List<ThreeMainList> findThreeMainList(Integer userID, Integer tableType) {
		// 需要返回的列表集合
		List<ThreeMainList> list = new ArrayList<>();
		// 指定科室或者大队列表
		List<ThreeMainList> findThreeMainList = threeTableDao.findThreeMainList(tableType, null);

		// start 筛选
		// 获取当前用户信息 判断级别 信息筛选
		User user = userDao.selectById(userID);
		if (user == null) {
			return null;
		}
		// 用户对应业务口 id 拼接字符
		String businessflag = user.getBusinessflag();
		// 职位
		String jobnumber = user.getcJobnumber();
		// 部门类型(1:支队 2:科室 3:大队 4 :中队)
		Integer departmentType = user.getDepartmentType();
		// 部门id
		Integer departmentID = user.getDepartmentId();
		// 支队主要负责人可见所有表格
		if (departmentType == 1 && "主要负责人".equals(jobnumber)) {
			return findThreeMainList;
		} else {
			if (tableType == 2) {// 科室
				// 检查人
				if (departmentType == 2 && "负责人".equals(jobnumber)) {
					ThreeTable findThreeTableById = null;
					int i = 0;
					for (ThreeMainList item : findThreeMainList) {
						findThreeTableById = threeTableDao.findThreeTableById(item.getThreeID());
						// 三查表检查部门
						String department = findThreeTableById.getDepartment();
						// 将部门id 拼接字符转换成 集合
						List<String> asList = Arrays.asList(department.split(","));
						// 业务口
						Integer selftype = findThreeTableById.getSelftype();
						List<String> asList2 = Arrays.asList(businessflag.split(","));
						// 判断三查表中自查部门是否存在当前用户所在部门 和 当前用户对应的业务口是否符合
						if (asList.contains(departmentID.toString()) && asList2.contains(selftype.toString())) {
							item.setTotal(++i);
							list.add(item);
						}
					}
				}
				// 分管部门抽查人
				if (departmentType == 1 && jobnumber.equals("负责人")) {
					ThreeTable findThreeTableById = null;
					for (ThreeMainList item : findThreeMainList) {
						findThreeTableById = threeTableDao.findThreeTableById(item.getThreeID());
						// 业务口
						Integer selftype = findThreeTableById.getSelftype();
						List<String> asList = Arrays.asList(businessflag.split(","));
						// 判断三查表中自查部门是否存在当前用户所在部门 和 当前用户对应的业务口是否符合
						if (asList.contains(selftype.toString())) {
							list.add(item);
						}
					}
				}

			} else if (tableType == 3) {// 大队
				// 检查人
				if (departmentType == 3 && jobnumber.equals("主要负责人")) {
					ThreeTable findThreeTableById = null;
					for (ThreeMainList item : findThreeMainList) {
						findThreeTableById = threeTableDao.findThreeTableById(item.getThreeID());
						// 三查表检查部门
						String department = findThreeTableById.getDepartment();
						// 将部门id 拼接字符转换成 集合
						List<String> asList = Arrays.asList(department.split(","));
						// 业务口
						// 判断三查表中自查部门是否存在当前用户所在部门 和 当前用户对应的业务口是否符合
						if (asList.contains(departmentID.toString())) {
							list.add(item);
						}
					}
				}
				// 检查人
				if (departmentType == 3 && jobnumber.equals("负责人")) {
					ThreeTable findThreeTableById = null;
					for (ThreeMainList item : findThreeMainList) {
						findThreeTableById = threeTableDao.findThreeTableById(item.getThreeID());
						// 三查表检查部门
						String department = findThreeTableById.getDepartment();
						// 将部门id 拼接字符转换成 集合
						List<String> asList = Arrays.asList(department.split(","));
						// 业务口
						Integer selftype = findThreeTableById.getSelftype();
						List<String> asList2 = Arrays.asList(businessflag.split(","));
						// 判断三查表中自查部门是否存在当前用户所在部门 和 当前用户对应的业务口是否符合
						if (asList.contains(departmentID.toString()) && asList2.contains(selftype.toString())) {
							list.add(item);
						}
					}
				}
				// 分管部门抽查人
				if (departmentType == 1 && jobnumber.equals("负责人")) {
					ThreeTable findThreeTableById = null;
					for (ThreeMainList item : findThreeMainList) {
						findThreeTableById = threeTableDao.findThreeTableById(item.getThreeID());
						// 业务口
						Integer selftype = findThreeTableById.getSelftype();
						List<String> asList = Arrays.asList(businessflag.split(","));
						// 判断三查表中自查部门是否存在当前用户所在部门 和 当前用户对应的业务口是否符合
						if (asList.contains(selftype.toString())) {
							list.add(item);
						}
					}
				}
				// 业务口对应科室人员抽查
				if (departmentType == 2) {
					ThreeTable findThreeTableById = null;
					for (ThreeMainList item : findThreeMainList) {
						findThreeTableById = threeTableDao.findThreeTableById(item.getThreeID());
						// 业务口
						Integer selftype = findThreeTableById.getSelftype();
						// 判断三查表中自查部门是否存在当前用户所在部门 和 当前用户对应的业务口是否符合
						if (departmentID == selftype) {
							list.add(item);
						}
					}
				}
			}
		}
		// 自增序列
		Integer integer = 0;
		for (ThreeMainList item : list) {
			integer++;
			item.setOrderID(integer);
		}
		return list;
	}

	@Override
	public Boolean updateThreeTaskSelf(Map<String, Object> map) {
		// 检查项
		ThreeTaskSelf taskSelf = (ThreeTaskSelf) map.get("taskSelf");
		// 把状态变为已完成
		boolean containsKey = map.containsKey("items");
		List<ThreeItem> items = null;
		if (containsKey) {
			items = JSON.parseArray(JSON.toJSONString(map.get("items")), ThreeItem.class);
		}
		Boolean falg = false;
		try {
			Integer updateTaskSelf = threeTaskSelfDao.updateThreeTaskSelf(taskSelf);
			if (updateTaskSelf > 0) {
				if (items != null) {
					logger.info("\n===== 检查项数量: " + items.size() + "====\n");
					Integer iRet = 0;
					for (ThreeItem item : items) {
						Integer updateThreeItem = threeItemDao.updateThreeItem(item);
						iRet = (updateThreeItem > 0) ? iRet++ : iRet;
					}
					logger.info("\n===== 修改成功: " + iRet + "====\n");
				}
				// 不通过发送到部门对应业务口负责人
				if(taskSelf.getState() == 3){
					// 当前自查用户
					Integer selfMan = taskSelf.getSelfMan();
					// 检查人
					Integer checkMan = taskSelf.getCheckMan();
					
					// 实例化消息对象
					Dope dope = new Dope();
					// 三查类型
					dope.setTitle("自查提醒");
					dope.setType(1);
					dope.setVisual(1);
					dope.setStatus(2);
					dope.setIfPop(1);
					dope.setPigment(1);
					dope.setTime(new Date());
					dope.setContent("三查表 : "+ taskSelf.getThreeName() +"\n\n自查人 : "+ userDao.selectById(selfMan).getcNickname() + "\n\n"+ "  自查不通过");
					// 负责接收人
					dope.setReceiveMan(String.valueOf(selfMan));
					dopeDao.addAppointManDope(dope);
					dope.setReceiveMan(String.valueOf(checkMan));
					dopeDao.addAppointManDope(dope);
				}
				falg = true;
			}
		} catch (Exception e) {
			falg = false;
			e.printStackTrace();
		}

		return falg;
	}

	@Override
	public List<ThreeTaskSelf> findThreeTaskSelf(FindThreeTaskSelf taskSelf) {
		return threeTaskSelfDao.findThreeTaskSelf(taskSelf);
	}

	@Override
	public Map<String, Object> findThreeTaskSelfByID(Integer id) {
		Map<String, Object> map = new HashMap<>();
		// 根据自查任务ID 查询任务详情
		ThreeTaskSelf selfTask = threeTaskSelfDao.findThreeTaskSelfByID(id);
		// 实例化一个Item
		ThreeItem item = new ThreeItem();
		item.setDetailsid(selfTask.getTaskID());
		// 根据任务Id 查询任务ID 下所有检查项
		List<ThreeItem> items = threeItemDao.findThreeItem(item);
		map.put("selfTask", selfTask);
		map.put("items", items);

		return map;
	}

	/**
	 * 修改检查项
	 * 
	 * @param items
	 * @return
	 */
	public Integer updateThreeItems(List<ThreeItem> items) {
		logger.info("\n========应修改检查项: " + items.size() + " 次 ========\n");
		// 修改次数标识
		Integer falg = 0;
		// 循环修改
		for (ThreeItem item : items) {
			Integer updateThreeItem = threeItemDao.updateThreeItem(item);
			falg = (updateThreeItem > 0) ? falg++ : falg;
		}
		logger.info("\n========成功修改检查项: " + falg + " 次 ========\n");
		return falg;
	}

	@Override
	public Integer addThreeCureIssue(InsertCureIssue issue) {

		return cureIssueDao.addThreeCureIssue(issue);
	}

	@Override
	public Integer updateThreeCureIssue(ThreeCureIssue issue) {
		return cureIssueDao.updateThreeCureIssue(issue);
	}

	@Override
	public List<CureIssueList> findThreeCureIssueList(Integer userID) {
		return cureIssueDao.findThreeCureIssueList(userID);
	}

	@Override
	public ThreeCureIssue findThreeCureIssueByID(Integer id) {
		return cureIssueDao.findThreeCureIssueByID(id);
	}

	@Override
	public Integer addTaskExternal(Integer selfTaskID) {
		return taskExternalDao.addTaskExternal(selfTaskID);
	}

	@Override
	public Boolean updateTaskExternal(ExternalSelfItems exteritems) {
		Boolean falg = false;
		// 修改外部任务状态为已完成
		Integer updateTaskExternal = taskExternalDao.updateTaskExternal(exteritems.getTaskID());
		if (updateTaskExternal > 0) {
			// 所有检查项
			List<ThreeItem> items = exteritems.getItems();
			logger.info("\n===== 检查项数量: " + items.size() + "====\n");
			Integer iRet = 0;
			// 循环修改所有检查项
			for (ThreeItem item : items) {
				Integer updateThreeItem = threeItemDao.updateThreeItem(item);
				if (updateThreeItem > 0)
					iRet++;
			}
			logger.info("\n===== 修改成功: " + iRet + "====\n");
			falg = true;
		}

		return falg;
	}

	@Override
	public List<ThreeTaskExternal> findTaskExternal(Integer userID) {
		return taskExternalDao.findTaskExternal(userID);
	}

	@Override
	public ExternalSelfItems findTaskExternalByID(Integer taskID, Integer selfTaskID) {
		ExternalSelfItems selfItems = new ExternalSelfItems();
		// 根据自查任务表ID 查询所有检查项
		// 实例化一个Item
		ThreeItem item = new ThreeItem();
		item.setDetailsid(selfTaskID);
		// 根据任务Id 查询任务ID 下所有检查项
		List<ThreeItem> items = threeItemDao.findThreeItem(item);
		selfItems.setTaskID(taskID);
		selfItems.setItems(items);
		return selfItems;
	}

	@Override
	public Map<String, String> getDepartmentMapByStrDecollator(String str, String decollator) throws Exception {
		Map<String, String> map = new HashMap<>();
		// 部门ID 数组
		String[] split = str.trim().split(decollator);
		// 部门实例
		Department findDepartmentById = null;
		for (int i = 0; i < split.length; i++) {
			findDepartmentById = departmentDao.findDepartmentById(Integer.parseInt(split[i]));
			// 部门ID 为键 名称为值
			map.put(findDepartmentById.getId().toString(), findDepartmentById.getName());
		}

		return map;
	}

	@Override
	public List<ReceiIissueMan> findReceiIissueMan(Integer threeId, String riskGrade, Integer userID) {
		// 查询接收问题清单人
		List<ReceiIissueMan> findReceiIissueMan = null;
		if (riskGrade.trim().equals("D") || riskGrade.trim().equals("B")) {
			// 查询接收问题清单人
			findReceiIissueMan = userDao.findReceiIissueMan(riskGrade, userID);
		} else if (riskGrade.trim().equals("C")) {
			findReceiIissueMan = new ArrayList<>();
			// 当前自查表的所属部门
			ThreeTable findThreeTable = threeTableDao.findThreeTableById(threeId);
			// 表格对应的业务口
			Integer selftype = findThreeTable.getSelftype();

			FindSelfCheckInspector findSelf = userDao.findSelfCheckInspector(selftype, userID);
			// 查询检查人信息
			User selectById = userDao.selectById(findSelf.getCheckID());
			ReceiIissueMan receiIissueMan = null;
			if (selectById != null) {
				receiIissueMan = new ReceiIissueMan();
				receiIissueMan.setUserID(selectById.getcUserId());
				receiIissueMan.setUserName(selectById.getcNickname());
				findReceiIissueMan.add(receiIissueMan);
			}
		}

		return findReceiIissueMan;
	}
}
